package io.zhengsh.jvm.oom;

import java.util.ArrayList;
import java.util.List;

// jVM ARG: -Xms4m -Xmx4m -XX:+PrintGCDetails -XX:MaxDirectMemorySize=4m
public class GCOverheadDemo {

    public static void main(String[] args) {
        int i = 0;
        List<String> list = new ArrayList<>();
        try {
            while (true) {
                list.add(String.valueOf(++i).intern());
            }
        } catch (Throwable t) {
            System.out.println("---------- i: " + i);
            t.printStackTrace();
            throw t;
        }
    }
}
